/*
*Copyright 2021-2023 NERCIS
*
*Licensed under the Apache License, Version 2.0 (the "License");
*you may not use this file except in compliance with the License.
*You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing, software
*distributed under the License is distributed on an "AS IS" BASIS,
*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*See the License for the specific language governing permissions and
*limitations under the License.
*/

package cn.ac.nercis.pes.common.constant.knowledge;


import org.apache.commons.lang3.StringUtils;

import java.util.List;

/**
 * 层面指标
 * @author zpy
 * @version 1.0.0
 */
public enum LayerTarget {
    /**物理和环境安全**/
    PHY_ENV(1,"物理和环境安全"),
    /**网络和通信安全**/
    NET_COMMUNICATION(2,"网络和通信安全"),
    /**设备和计算安全**/
    DEVICE_COMPUTE(3,"设备和计算安全"),
    /**应用和数据安全**/
    APP_DATA(4,"应用和数据安全"),
    /**管理制度**/
    MANAGE_SYSTEM(5,"管理制度"),
    /**人员管理**/
    PERSONNEL_MANAGE(6,"人员管理"),
    /**建设运行**/
    BUILD_RUNNING(7,"建设运行"),
    /**应急处置**/
    EMERGENCY_HANDLING(8,"应急处置");

    private final Integer value;
    private final String name;

    LayerTarget(Integer value, String name) {
        this.value = value;
        this.name = name;
    }

    public static LayerTarget fromName(String name){
        LayerTarget data = null;
        for(LayerTarget tt : LayerTarget.values()){
            if(StringUtils.equals(tt.name,name)){
                data = tt;
                break;
            }
        }
        return data;
    }

    public static List<LayerTarget> findTechnologyLayer(){
        return List.of(PHY_ENV,NET_COMMUNICATION,DEVICE_COMPUTE,APP_DATA);
    }

    public static List<LayerTarget> findManagementLayer(){
        return List.of(MANAGE_SYSTEM,PERSONNEL_MANAGE,BUILD_RUNNING,EMERGENCY_HANDLING);
    }

    public Integer getValue(){
        return this.value;
    }

    public String getName(){
        return this.name;
    }

}